package Ventanas;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.ListSelectionModel;
import javax.swing.border.BevelBorder;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.JSeparator;
import javax.swing.JButton;
import javax.swing.ImageIcon;
import javax.swing.JLabel;

import Clases.Reparacion;

import java.awt.Font;
import java.awt.Label;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.print.PrinterException;
import java.util.ArrayList;

public class vMisReparaciones extends JFrame {

	private JPanel contentPane;
	private JTable table;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					vMisReparaciones frame = new vMisReparaciones();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public vMisReparaciones(ArrayList<Reparacion> aReparaciones) {
		setResizable(false);
		setTitle("Mis reparaciones");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 910, 565);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		// borrar
		int hola=0;
		table = new JTable();
		table.setColumnSelectionAllowed(true);
		table.setSurrendersFocusOnKeystroke(true);
		table.setCellSelectionEnabled(true);
		table.setFont(new Font("Vani", Font.PLAIN, 11));
		table.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
		table.setFillsViewportHeight(true);
		table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
		table.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null, null, null, null, null},
			},
			new String[] {
				"Numero_Reparacion", "Empleado", "Nom_Cliente", "Observaciones", "Problema", "Precio"
			}
		));
		table.getColumnModel().getColumn(5).setResizable(false);
		table.setBounds(10, 79, 863, 416);
		contentPane.add(table);
		
		JButton button = new JButton("");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setVisible(false);
				vInicioCliente.vSC.setVisible(true);
			}
		});
		button.setIcon(new ImageIcon(vMisReparaciones.class.getResource("/Img/arrow_left.png")));
		button.setBounds(10, 11, 89, 23);
		contentPane.add(button);
		
		JSeparator separator = new JSeparator();
		separator.setBounds(10, 45, 863, 2);
		contentPane.add(separator);
		
		Label label = new Label("     Numero_Reparacion                    Empleado                              Nom_Cliente                                 Observaciones                         Problema                Precio");
		label.setBackground(Color.GRAY);
		label.setBounds(10, 51, 863, 22);
		contentPane.add(label);
		
		Label label_1 = new Label("Historial de reparaciones");
		label_1.setFont(new Font("Dialog", Font.PLAIN, 22));
		label_1.setBounds(321, 11, 336, 27);
		contentPane.add(label_1);
		
		JButton btnNewButton = new JButton("Imprimir");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try {
					table.print();
				} catch (PrinterException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
					JOptionPane.showMessageDialog(null,"Ocurrio un problema con la impresora");
				}
			}
		});
		btnNewButton.setBounds(715, 11, 109, 27);
		contentPane.add(btnNewButton);
	}
}
